package com.example.utils;

import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.IOException;

/**
 * json转化工具类
 */
public class JsonChangeObject {


    /**
     * 读取前端传递过来的参数，转化为字符串
     * @param req
     * @return
     * @throws IOException
     */
    public static String JsonObject(HttpServletRequest req) throws IOException {
        StringBuilder buffer = new StringBuilder();
        BufferedReader reader = req.getReader();
        String line;
        while ((line = reader.readLine()) != null) {
            buffer.append(line);
        }
        return buffer.toString();
    }
}
